package com.example.demo.api;

import com.example.demo.domain.CourseInfo;
import com.example.demo.domain.Student;
import com.example.demo.service.StudentService;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * restful风格
 */
@RestController
@RequestMapping("/api/student")
public class StudentApiController {
    @Autowired
    private StudentService studentService;

    @Autowired
    private Gson gson;

    @GetMapping(value="/getAllStudents")
    public List<Student> findStudent(){
        List<Student> myAll = studentService.findAll();
        return myAll;
    }

    @GetMapping("/byName")
    public List<Student> findStudentByName(@RequestParam("studentName") String StudentName) {
        List<Student> student = studentService.findByStudentNameLike(StudentName);
        return student;
    }

}
